﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="ncp.Web.cms.Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="css/login.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function onfresh() {
    	    var rand = Math.random() * 1000;
    	    $("#checkImage").attr("src", "/work/VerificationCode.aspx?" + rand);
    	}
    	function login() {
    	    $(".safe-tips").html("");
    	    var username = $.trim($("#textAccount").val());
    	    var pwd = $("#textPwd").val();
    	    var verifycode = $("#verifycode").val();
    	    if (username == "") {
    	        $(".safe-tips").html("用户名不能为空！");
    	        $("#textAccount").focus();
    	        return;
    	    }
    	    if (pwd == "") {
    	        $(".safe-tips").html("密码不能为空！");
    	        $("#textPwd").focus();
    	        return;
    	    }
    	    if (verifycode == "") {
    	        $(".safe-tips").html("验证码不能为空！");
    	        $("#verifycode").focus();
    	        return;
    	    }
    	    var rep = ncp.Web.cms.Login.VerificationCode(verifycode);
    	    if (rep.value != null) {
    	        var jsonOBJ = eval(rep.value)[0];
    	        if (!jsonOBJ.isreload) {
    	            $(".safe-tips").html("验证码错误");
    	            onfresh();
    	            return;
    	        }
    	        var response = ncp.Web.cms.Login.UserLogin(username, pwd);
    	        if (response.value != "") {
    	            var jsonOBJ = eval(response.value)[0];
    	            if (jsonOBJ.isreload) {
    	                location.href = jsonOBJ.msg;
    	            } else
    	                $(".safe-tips").html(jsonOBJ.msg);
    	        }
    	    }
    	}
    	$(function() {
    	    //回车触发登录按钮
    	$("#textAccount,#textPwd,#verifycode").keypress(function(e) {
    	        var key = window.event ? e.keyCode : e.which;
    	        if (key.toString() == "13") {
    	            login();
    	            return false;
    	        }
    	    });
    	});
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="login-box">
   <div class="login-top"><a href="../../index.aspx" target="_blank" title="返回网站主页">返回网站主页</a></div>
   <div class="safe-tips"></div>
   <div class="login-main">
      <dl>
	   <dt>用户名：</dt>
	   <dd><input type="text" name="userid" id="textAccount"></dd>
	   <dt>密&nbsp;&nbsp;码：</dt>
	   <dd><input type="password" class="alltxt" name="pwd" id="textPwd"></dd>
	   <dt>验证码：</dt>
	   <dd>
	   <input type="text" class="alltxt" style="width: 50px;float: left;" name="verCode" id="verifycode">
	   <img id="checkImage" src="/work/VerificationCode.aspx" width="60" height="25"  alt="验证码"　title="验证码" />
	   <span style="font-size: 9pt;"><a href="javascript:void(0)" onclick="onfresh()">换一张</a></span>
	   </dd>
	   		<dt>&nbsp;</dt>
		<dd><button type="button" name="sm1" class="login-btn" onclick="login()">登录</button></dd>
	 </dl>
   </div>
   <div class="login-power">Powered by<a href="../../index.aspx" title="中国农业信息化服务网"><strong>中国农业信息化服务网</strong></a>© 2012 </div>
</div>
    </form>
</body>
</html>
